<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="format-detection" content="telephone=no">
    <meta name="viewport" content="minimal-ui,width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <title>快速购买-{$webseting.web_title}</title>
    <link href="__PUBLIC__/wap/css/rest.css"  rel="stylesheet">
    <link href="__PUBLIC__/wap/css/user.css"  rel="stylesheet">
    <link href="__PUBLIC__/wap/css/ordertracking.css"  rel="stylesheet">
</head>
<body id="u-body">
    <header id="header" class="u-header clearfix">
        <div class="u-hd-left f-left">
            <a href="javascript:history.go(-1);" class="J_backToPrev"><span class="u-icon-px i-hd-back"></span></a>
        </div>
        <div class="u-hd-tit"><span>快速购买</span></div>
    </header>
    <div class="fm-wrap">
        <form action="" role="form" id="form2" novalidate="novalidate" method="post" onSubmit="return false;">
           <input class="text_box text_border" type="hidden" name="code" id="code"  value="{$_SESSION['share']}" placeholder="请输入推荐人手机号码/推荐码" maxlength="11">
            <section class="miblewrap01 goods-return-type">
                <div class="check-cnt">
                    <div class="check-cnt-box" id="check-cnt-box2">
                        <p class="msg-text">使用手机号码进行便捷注册</p>
                    </div>
                    <div class="check-cnt-box always-show">
                        <div class="fm-form" style="margin-top: 5px">
                            <div class="fm-item">
                                <span class="label">账号：</span>
                                <div class="item-col">
                                    <input type="text" class="fm-text al" value="" name="mobile" id="mobile"  placeholder="输入手机号码"></div>
                            </div>
                            <div class="fm-item">
                                <span class="label">验证码：</span>
                                <div class="item-col">
                                    <input type="text" class="fm-text al" name="mobile_code" id="mobile_code" value="" placeholder="短信验证码" style="width: 50%">
                                    <a href="javascript:void(0);" class="f-yzm send_sms">
                                        <span class='get_sms'>获取验证码</span>
                                        <span class="countdown" style="display:none;">（<em class="num">60</em>S）</span>
                                    </a>
                                </div>
                            </div>
                            <div class="fm-item">
                                <span class="label">密码：</span>
                                <div class="item-col">
                                    <input type="password" class="fm-text al" name="mem_password" id="mem_password" value="" placeholder="密码">
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </section>
          
            <section class="miblewrap01 goods-return-type" style="display: block;">
                <h3 class="mible-tit01">确认收货信息</h3>
                <div class="fm-form">
                    <div class="fm-item">
                        <span class="label">联系人：</span>
                        <div class="item-col">
                            <input type="text" class="fm-text al" value=""  placeholder="联系人" id="consignee" name="consignee"></div>
                    </div>
                    <input name="cart_id"  type="hidden" value="{$_GET['cart_id']}">
                    <div class="fm-item">
                        <span class="label">收货地址：</span>
                        <div class="item-col">
                            <span class="fm-sele-box fm-sele-box01">
                                <span class="fm-select-text city_name_p">请选择</span>
                                 <select  class="fm-select city_p"  data="p"  id="province" name="province" onchange="choice_province('city')">
                                    <option value="0">请选择</option>
                                    <volist name="citylist['province']" id="vo">
                                    <option value="{$vo.cityid}" >{$vo.cityname}</option>
                                    </volist>    
                                </select>
                            </span>
                            <span class="fm-sele-box fm-sele-box01">
                                <span class="fm-select-text city_name_c">请选择</span>
                                <select id="city" name="city" {$disable} onchange="choice_city('city')" data="c" class="fm-select city_c"  >
                                    <option selected="selected" value="0">请选择</option>
                                </select>
                            </span>
                            <span class="fm-sele-box fm-sele-box01">
                                <span class="fm-select-text city_name_a">请选择</span>
                                <select id="area" name="area"  class="fm-select city_a" data="a">
                                    <option selected="selected" value="0">请选择</option>
                                </select>
                            </span>
                        </div>
                    </div>
                    <div class="fm-item">
                        <span class="label">&nbsp;</span>
                        <div class="item-col">
                            <input type="text"  placeholder="收货地址详细" class="fm-text" name="address" id="address" value="">
                        </div>
                    </div>
                    <p id="p002" class="msg-text" style="margin-top: 5px">如果您修改地址，请确认上方“省、市、县”是否需要修改<br>
                    注册即视为同意FG峰购<a href="{:U('wap/login/fuwu')}">《用户协议》</a>
                    </p>
                </div>
            </section>
        </form>
        <div class="fm-btns"><a href="javascript:;" class="btn-h3 btn-c3 phone_log_btn">提交</a></div>
    </div>
    
<script>
    var get_city_url="{:U('wap/index/get_city')}";
    </script>  
     <include file="Public/wap_javascript" />  >
     <!--微信分享-->    
 <include file="Public/share_weixin" />
    
     
     
   
        <script>
jQuery(document).ready(function() {
                //FormValidator.init();
jQuery.validator.addMethod("byteRangeLength", function(value) {
    var areaid=$("#area").val();
    var cityid=$("#city").val();
    var provinceid=$("#province").val();
    var ret=false;
    if(areaid>0 && cityid>0 && provinceid>0){
       ret=true;
    }
  return ret;   
});

$("#form2").validate({
  rules: {
    mobile: {
    required:true,
    number:true,
    maxlength:11,
    minlength:11,
    remote: {
            url: "{:U('Wap/Login/cheack_mobile')}",
            type: "get",
            dataType: "json",
            data: {
                mobile: function () {
                    return $("#mobile").val();　　　　//这个是取要验证的数据
                }
            },
            dataFilter: function (msg) {　　　　//判断控制器返回的内容
                if (msg == "0") {
                    return true;
                }else {
                    return false;
                }
            }
        }
   },
    mobile_code: {
    required:true,
    remote: {
            url: "{:U('Wap/Login/check_send_reg')}",
            type: "get",
            dataType: "json",
            data: {
                mobile: function () {
                    return $("#mobile").val();　　　　//这个是取要验证的数据
                },
                mobile_code: function () {
                    return $("#mobile_code").val();　　　　//这个是取要验证的数据
                }
            },
            dataFilter: function (msg) {　　　　//判断控制器返回的内容
                if (msg == "1") {
                    return true;
                }else {
                    return false;
                }
            }
        }
   },
   mem_password: {
                    required: true,
                    rangelength: [6, 20]
                },
   consignee: 'required',
   area: 'byteRangeLength',
   address:'required'
  },
  messages: {
        mobile:{
        required:'<span class="icon-warning icon_warning"></span>&nbsp;请输入手机号码',
        number:'<span class="icon-warning icon_warning"></span>&nbsp;请输入正确的手机号码',
        maxlength:'<span class="icon-warning icon_warning"></span>&nbsp;请输入正确的手机号码',
        minlength:'<span class="icon-warning icon_warning"></span>&nbsp;请输入正确的手机号码',
        remote:'<span class="icon-warning icon_warning"></span>&nbsp;手机号码已注册'
       },
        mobile_code: {
        required:'<span class="icon-warning icon_warning"></span>&nbsp;请输入手机验证码',
        remote:'<span class="icon-warning icon_warning"></span>&nbsp;手机验证码不正确'
       },
        mem_password: {
        required:'<span class="icon-warning icon_warning"></span>&nbsp;请输入密码',
        rangelength:'<span class="icon-warning icon_warning"></span>&nbsp;密码请保持6-20位'
       },
       consignee:'<span class="icon-warning icon_warning"></span>&nbsp;请输入联系人',
       area: '<span class="icon-warning icon_warning"></span>&nbsp;请选择完整的省市区',
       address:'<span class="icon-warning icon_warning"></span>&nbsp;请输入详细地址'
  },
   focusInvalid:false,
  success: function(label) { 
            // set  as text for IE 
           // alert('ok'); 
            //label.html(" ").addClass("checked"); 
        }, 
        /*执行ajaxsubmit  */ 
        submitHandler: function(editform) { 

            var options = { 
                url :  "<?php echo U('Wap/Fastbuy/index'); ?>", 
                type : "post" , 
                dataType:'json', 
                target : "#loader", 
                error: function(){layer.msg("服务器没有返回数据，可能服务器忙，请重试",{icon:5});}, 
                onwait : "正在处理信息，请稍候...",
                success: function(response){ 
                       console.log(response);
                    //$("#loader").fadeIn(500).html(response.data).fadeOut(500); 
                    //$('#editform').hide(2000); 
                    if(response.status==1){
window.location.href="<?php echo U('wap/goodsorder/order_pay'); ?>?pay_sn="+response.pay_sn; 
                    }else{
                        layer.msg(response.error,{icon:5});
                    }
                }
            };
            setTimeout((function(opt){
                return function(){
                    $('#form2').ajaxSubmit(opt);
                }
            })(options), 300); 
            return false; 
        }

  });

$('.phone_log_btn').click(function(){
    $('#form2').submit();
});


$('.send_sms').click(function(){
    var is_send=$(this).hasClass('disable');
    if(is_send){
      return false;
    }else{
        //短信发送
         $.ajax({
            url: "{:U('Wap/Login/send_sms_fastreg')}",
            type: "get",
            dataType: "json",
            data: {
                mobile: function () {
                    return $("#mobile").val();　　　　//这个是取要验证的数据
                }/*,
                verify_code: function () {
                    return $("#verify_code").val();　　　　//这个是取要验证的数据
                }*/
            },
            success: function (msg) {　　　　//判断控制器返回的内容
                if (msg.status == "1") {
                     //disable
                     //$('#mobile_code').val(msg.code);
                      layer.msg("验证码发送成功",{icon:6});
                     run_time_out();
                }else {
                    layer.msg(msg.msg,{icon:5});
                }
            }
       });
    }
});
$('.fm-select').change(function(){
    var val=$(this).val();
    var data=$(this).attr('data');
      var data_no=$(this).find("option:selected").html();
      if(val>0){
         $('.city_name_'+data).css('color','#666');
      }else{
        $('.city_name_'+data).css('color','#b9b9b9');
      }
      if(data=="p"){
         $('.city_name_c').css('color','#b9b9b9');
         $('.city_name_c').html("请选择");
         $('.city_name_a').css('color','#b9b9b9');
         $('.city_name_a').html("请选择");
      }else if(data=="c"){
        $('.city_name_a').css('color','#b9b9b9');
         $('.city_name_a').html("请选择");
      }
     $('.city_name_'+data).html(data_no);
});

});
function run_time_out(){
    var num=$('.num').html();
    num=parseInt(num);
    var is_send=$('.send_sms').hasClass('disable');
    if(num>0){
        $('.countdown').show();
        num--;
        $('.num').html(num);//显示倒计时
        if(!is_send){
          $('.send_sms').addClass('disable');///禁止点击
          $('.send_sms').css('cssText','background-color: #eee;color: #666;');
          $('.get_sms').hide();
        }
    }else{
       $('.countdown').hide();
       $('.num').html(60);//初始化倒计时
       $('.send_sms').removeClass('disable');///可以点击
        $('.send_sms').removeAttr('style');
       $('.get_sms').show();
      return false;
    }
    setTimeout('run_time_out()',1000); 
}
</script>    
</body>
</html>